/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

typedef long long ll;

constexpr int maxn = 5e7;

ll f[maxn];

ll solve(ll x) {
  if (x < maxn && f[x]) return f[x];
  if (x == 0) return 1;
  ll res = solve(x / 2) + solve(x / 3);
  if (x < maxn) f[x] = res;
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << solve(n);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("D - Yet Another Recursive Function.in", "r", stdin);
  freopen("D - Yet Another Recursive Function.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
